package com.zyjedu.controller;

import com.zyjedu.mvcframework.annotation.ZYJAutowired;
import com.zyjedu.mvcframework.annotation.ZYJController;
import com.zyjedu.mvcframework.annotation.ZYJRequestMapping;
import com.zyjedu.mvcframework.annotation.ZYJRequestParam;
import com.zyjedu.service.DemoService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@ZYJController
@ZYJRequestMapping("/demo")
public class DemoController {

    @ZYJAutowired
    private DemoService demoService;

    @ZYJRequestMapping("/get")
    public void query(HttpServletRequest request, HttpServletResponse response, @ZYJRequestParam("name") String name) {
        String result = demoService.get(name);

        try {
            response.getWriter().write(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
